package com.starlight.flower_server.controller;


import com.starlight.flower_server.controller.authentication.AuthenticationCheck;
import com.starlight.flower_server.infrastructure.FlowerServerResponse;
import com.starlight.flower_server.domain.service.FlowerUserRoleService;
import com.starlight.flower_server.infrastructure.RoleType;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author yfy2001
 * @date 2023/4/5 15:29
 * 用户权限控制
 */
@RestController
@RequestMapping("/userRole")
public class FlowerUserRoleController {
    @Resource
    private FlowerUserRoleService flowerUserRoleService;

    @PostMapping("/updateUserRoleById")
    @AuthenticationCheck(roleType = {RoleType.ROOT})
    public FlowerServerResponse<Integer> updateUserRoleById(Long id, Long roleId){
        return FlowerServerResponse.success(flowerUserRoleService.modifyUserRoleById(id,roleId));
    }

    @PostMapping("/banUserById")
    @AuthenticationCheck(roleType = {RoleType.ROOT})
    public FlowerServerResponse<Integer> banUserById(Long id){
        return FlowerServerResponse.success(flowerUserRoleService.banUserById(id));
    }

    @PostMapping("/recoverUserRoleById")
    @AuthenticationCheck(roleType = {RoleType.ROOT})
    public FlowerServerResponse<Integer> recoverUserRoleById(Long id){
        return FlowerServerResponse.success(flowerUserRoleService.recoverUserById(id));
    }
}
